<?php
namespace Plugin\Attractions\Commerce\Schema\Commerce_commodity;

use Plugin\Attractions\Commerce\Model\Commerce_commodity\CommerceCommodity;
use Hyperf\Swagger\Annotation\Property;
use Hyperf\Swagger\Annotation\Schema;

/**
 * 商品
 */
#[Schema(title: 'CommerceCommoditySchema')]
class CommerceCommoditySchema implements \JsonSerializable
{
    #[Property(property: 'id', title: '主键ID', type: 'bigint')]
    public string $id;

    #[Property(property: 'merchant_id', title: '商户ID', type: 'bigint')]
    public string $merchant_id;

    #[Property(property: 'commodity_name', title: '商品名称', type: 'varchar')]
    public string $commodity_name;

    #[Property(property: 'commodity_category', title: '商品分类', type: 'int')]
    public string $commodity_category;

    #[Property(property: 'commodity_brand', title: '商品品牌', type: 'varchar')]
    public string $commodity_brand;

    #[Property(property: 'commodity_model', title: '商品型号', type: 'varchar')]
    public string $commodity_model;

    #[Property(property: 'commodity_spec', title: '商品规格', type: 'array')]
    public array $commodity_spec;

    #[Property(property: 'commodity_unit', title: '计量单位', type: 'varchar')]
    public string $commodity_unit;

    #[Property(property: 'commodity_description', title: '商品描述', type: 'text')]
    public string $commodity_description;

    #[Property(property: 'sale_price', title: '销售价', type: 'decimal')]
    public string $sale_price;

    #[Property(property: 'discount', title: '折扣', type: 'decimal')]
    public string $discount;

    #[Property(property: 'full_amount', title: '满减满足金额', type: 'decimal')]
    public string $full_amount;

    #[Property(property: 'full_reduction', title: '满减扣除金额', type: 'decimal')]
    public string $full_reduction;

    #[Property(property: 'stock_quantity', title: '库存数量', type: 'int')]
    public string $stock_quantity;

    #[Property(property: 'sales_quantity', title: '销售数量', type: 'int')]
    public string $sales_quantity;

    #[Property(property: 'commodity_images', title: '商品图片（JSON格式）', type: 'array')]
    public array $commodity_images;

    #[Property(property: 'status', title: '商品状态：1-上架，2-下架', type: 'tinyint')]
    public string $status;

    #[Property(property: 'sort_order', title: '排序', type: 'int')]
    public string $sort_order;

    #[Property(property: 'remark', title: '备注', type: 'text')]
    public string $remark;

    #[Property(property: 'created_at', title: 'created_at', type: 'timestamp')]
    public string $created_at;

    #[Property(property: 'updated_at', title: 'updated_at', type: 'timestamp')]
    public string $updated_at;




    public function __construct(CommerceCommodity $model)
    {
       $this->id = $model->id;
       $this->merchant_id = $model->merchant_id;
       $this->commodity_name = $model->commodity_name;
       $this->commodity_category = $model->commodity_category;
       $this->commodity_brand = $model->commodity_brand;
       $this->commodity_model = $model->commodity_model;
       $this->commodity_spec = $model->commodity_spec;
       $this->commodity_unit = $model->commodity_unit;
       $this->commodity_description = $model->commodity_description;
       $this->sale_price = $model->sale_price;
       $this->discount = $model->discount;
       $this->full_amount = $model->full_amount;
       $this->full_reduction = $model->full_reduction;
       $this->stock_quantity = $model->stock_quantity;
       $this->sales_quantity = $model->sales_quantity;
       $this->commodity_images = $model->commodity_images;
       $this->status = $model->status;
       $this->sort_order = $model->sort_order;
       $this->remark = $model->remark;
       $this->created_at = $model->created_at;
       $this->updated_at = $model->updated_at;

    }

    public function jsonSerialize(): array
    {
        return ['id' => $this->id ,'merchant_id' => $this->merchant_id ,'commodity_name' => $this->commodity_name ,'commodity_category' => $this->commodity_category ,'commodity_brand' => $this->commodity_brand ,'commodity_model' => $this->commodity_model ,'commodity_spec' => $this->commodity_spec ,'commodity_unit' => $this->commodity_unit ,'commodity_description' => $this->commodity_description ,'sale_price' => $this->sale_price ,'discount' => $this->discount ,'full_amount' => $this->full_amount ,'full_reduction' => $this->full_reduction ,'stock_quantity' => $this->stock_quantity ,'sales_quantity' => $this->sales_quantity ,'commodity_images' => $this->commodity_images ,'status' => $this->status ,'sort_order' => $this->sort_order ,'remark' => $this->remark ,'created_at' => $this->created_at ,'updated_at' => $this->updated_at];
    }
}